clear all
set more off
capture log close
log using "$output/table1.log", replace

version 16	

use "$data\acsmergeddata.dta", clear

gen spmdeeppoor=(spm_resources<spm_povthreshold/2)

gen famincog=faminc
gen faminceitc=faminc+v25
gen famincctc17=faminc+totctc2017
gen famincctc18=faminc+totctc2018
gen faminceitcctc17=famincctc17+v25
gen faminceitcctc18=famincctc18+v25
gen faminceitcctc21=famincctc21+v25

foreach var in og ctc21 ctc18 ctc17 eitc eitcctc17 eitcctc18 eitcctc21{
	gen pr`var'=(faminc`var'<spm_povthreshold)	
	gen dppr`var'=(faminc`var'<(spm_povthreshold/2))
}

foreach var in ctc21 ctc17 ctc18 eitc eitcctc17 eitcctc18 eitcctc21{
	gen nomasprog`var'=(prog==1 & pr`var'==0)
	gen stillprog`var'=(prog==1 & pr`var'==1)

	gen nomasdpprog`var'=(dpprog==1 & dppr`var'==0)
	gen stilldpprog`var'=(dpprog==1 & dppr`var'==1)
}
sum nomas*pr*
sum still*pr*	

gen pop=(perwt + spouseperwt)
egen totadults=sum(pop)
di totadults
drop pop

gen pop=(newnumkidswt17)
egen totkids=sum(pop)
di totkids
drop pop

*** total SPM poor
gen pop=(perwt + spouseperwt)*spm_poor
egen poortotadults=sum(pop)
di poortotadults
drop pop poortotadults

gen pop=(newnumkidswt17)*spm_poor
egen poortotkids=sum(pop)
di poortotkids
drop pop poortotkids

*** total SPM deep poor
gen pop=(perwt + spouseperwt)*spmdeeppoor
egen deeppoortotadults=sum(pop)
di deeppoortotadults
drop pop deeppoortotadults

gen pop=(newnumkidswt17)*spmdeeppoor
egen deeppoortotkids=sum(pop)
di deeppoortotkids
drop pop deeppoortotkids

*** total poor without CTC or EITC
gen pop=(perwt + spouseperwt)*poor
egen poortotadults=sum(pop)
di poortotadults
drop pop

gen pop=(newnumkidswt17)*poor
egen poortotkids=sum(pop)
di poortotkids
drop pop

*** total poor without CTC or EITC
gen pop=(perwt + spouseperwt)*dpprog
egen deeppoortotadults=sum(pop)
di deeppoortotadults
drop pop

gen pop=(newnumkidswt17)*dpprog
egen deeppoortotkids=sum(pop)
di deeppoortotkids
drop pop

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the EITC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogeitc)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogeitc)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogeitc)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogeitc)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the 2017 CTC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the 2018 CTC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the 2021 CTC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the 2017 CTC + EITC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogeitcctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogeitcctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogeitcctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogeitcctc17)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the EITC + 2018 CTC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogeitcctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogeitcctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogeitcctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogeitcctc18)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

***************************************************************************
*** parents and kids pulled out of poverty and deep poverty by the EITC + 2021 CTC
***************************************************************************

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasprogeitcctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasprogeitcctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/poortotkids
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(perwt+spouseperwt)*(nomasdpprogeitcctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotadults
drop totparents1 totparents2 totparents3

forvalues i=1/3{
gen parents`i'=(newnumkidswt17)*(nomasdpprogeitcctc21)*(calckids==`i')
egen totparents`i'=sum(parents`i')
drop parents`i'
}
di totparents1+totparents2+totparents3
di (totparents1+totparents2+totparents3)/deeppoortotkids
drop totparents1 totparents2 totparents3

log close